import request from "../../utils/request";

const authApi = {
  login: (params: {
    captchaId: string;
    captchaText: string;
    username?: string;
    password: string;
    email?: string;
  }) =>
    request<API.Response<string>>("/user/auth/login", {
      method: "POST",
      body: params,
    }),
  register: (params: {
    avatar?: string;
    captchaId: string;
    captchaText: string;
    company?: string;
    email: string;
    introduce?: string;
    nickname: string;
    password: string;
    sex?: string; // 1 男 2 女 0 未知
    username: string;
  }) =>
    request<API.Response<string>>("/user/auth/signIn", {
      method: "POST",
      body: params,
    }),
  forgotPassword: (params: {
    email: string;
    captchaId: string;
    captchaText: string;
  }) =>
    request<API.Response<boolean>>("/user/auth/forgot_password", {
      method: "POST",
      body: params,
    }),
  getCaptcha: () =>
    request<API.Response<{ captchaId: string; captcha: string }>>("/captcha", {
      method: "GET",
    }),
};
export default authApi;
